
/*

Author   : chaos

FileName : call_val.cpp

Date     : 08/08/17 18:39:45

*/
#include <iostream>
using namespace std;

int arith(int ,int ,int);
int main(void)
{
    int first_term = 100 ,n_term = 1, step = 1;

    cout << "before funciton call ..." << endl;
    cout << "first_term = " << first_term << endl;
    cout << "n_term = " << n_term << endl;
    cout << "step = " << step << endl;

    cout << endl << "The sum from 1 to 100 step 1 is " << arith(first_term,n_term,step) << endl << endl;

    cout << "before funciton call ..." << endl;
    cout << "first_term = " << first_term << endl;
    cout << "n_term = " << n_term << endl;
    cout << "step = " << step << endl;



    return 0;
}


int arith(int under_value,int up_value, int step){
    int n , temp , total = 0;

    if(up_value < under_value){
        temp = up_value;
        up_value = under_value;
        under_value = temp;
    }
    n = (up_value - under_value)/step+1;

    total = (up_value +under_value)*n/2;

    return total;
}
